﻿Imports System.Data.SqlClient

Public Class adm_addColumn
    Inherits System.Web.UI.Page
    Private objrd As SqlDataReader = Nothing
    Private objfind As New GetData
    Private sSQL As String
    Private ps As New PreparedStatement(sSQL)

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        If (Session("admin_ID") <> Nothing And Session("admin_ID") <> "") Then
        Else
            Response.Redirect("../adm_login.aspx")
        End If
    End Sub

    Protected Sub btnCancel_Click(sender As Object, e As EventArgs) Handles btnCancel.Click
        Response.Redirect("col_default.aspx")
    End Sub

    Protected Sub btnCreate_Click(sender As Object, e As EventArgs) Handles btnCreate.Click
        Dim strErr As String = ""
        Dim strName, language As String
        strName = Cname.Text
        If en.Checked = True Then
            language = "en"
        Else
            language = "zh"
        End If
        If strName = "" Then
            result.InnerHtml = ""
            result.InnerHtml = "<center><b><font color=""#FF0000""> Please enter your Column name</font></b></center>"
            Exit Sub
        End If
        sSQL = "insert into Columns(Column_Name,lang_flag) values (@cname,@language)"
        ps.addParameter("language", language)
        ps.addParameter("cname", strName)
        ps.strSql = sSQL
        objfind.es(ps, strErr)
        If strErr = Nothing Or strErr = "" Then
            result.InnerHtml = ""
            result.InnerHtml = "<center><b><font color=""#FF0000""> Add Column Success！</font></b></center>"
            Cname.Text = ""
        Else
            result.InnerHtml = ""
            result.InnerHtml = "<center><b><font color=""#FF0000"">Error！</font></b><p>" & strErr & "</p></center>"
        End If
    End Sub
End Class